<?
/**
 * This file is part of XNAT light.
 *
 * XNAT light is free software: you can redistribute it and/or modify
 * it under the terms of the GNU General Public License as published by
 * the Free Software Foundation, either version 3 of the License, or
 * (at your option) any later version.
 *
 * XNAT light is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU General Public License for more details.
 *
 * You should have received a copy of the GNU General Public License
 * along with XNAT light.  If not, see <http://www.gnu.org/licenses/>.
 */
if($this->error)
{
    $array = array("error" => $this->message);

    echo json_encode($array);

    exit();
}

$width = "480px";

// customize this template per deployment
$content = '
<html>
    <body>
	<table width="100%" border="0" cellspacing="0" cellpadding="0" align="center">
	    <tbody>
		<tr>
		    <td style="padding 20px 20px 40px 20px">
			<table cellpadding="0" cellspacing="0" border="0" width="620">
			    <tbody>
				<tr>
				    <td style="background-color:#ededed;border:1px grey;padding:5px 5px 5px 5px;vertical-align:middle"><img height="60" src="http://foobar.com/shield.png" alt="Shield" /></td>
				    <td style="background-color:#ededed;border:1px grey;padding:5px 5px 5px 10px;vertical-align:middle;font-size:25px;font-family:verdana;text-align:left;width:100%;font-weight:bold">Institution Name</td>
				</tr>
				<tr>
				    <td style="padding:20px 20px 20px 20px;border-right:1px solid #cccccc;border-left:1px solid #cccccc;border-bottom:1px solid #cccccc;font-size:18px" colspan="2"><pre style="white-space:pre-wrap">' . $this->body . '</pre></td>
				</tr>
			    </tbody>
			</table>
		    </td>
		</tr>
	    </tbody>
	</table>
      </body>
</html>';

echo "
<table border='1'>
	<tr>
		<td>To</td>
		<td>$this->to</td>
	</tr>
	<tr>
		<td>From</td>
		<td>$this->from</td>
	</tr>
	<tr>
		<td>Subject</td>
		<td>$this->subject</td>
	</tr>
</table>";

echo "<br />";
echo $content;
echo "<br />";

//send email
ini_set("SMTP", "smtp.server.org");
$status = mail($this->to, $this->subject, $content, $this->headers);

if($status)
	echo "Success: yes";
else
	echo "Success: no";
